#include "AtlasDefines.h"
#include "AtlasUUID.h"

#ifdef _WIN32
#include <Rpc.h>
#include <Rpcdce.h>

void AUuidToString(const A_UUID& uuid, char* str)
{
	RPC_CSTR val;
	UuidToStringA((UUID*)&uuid, &val);
	strcpy(str, (const char*)val);
	RpcStringFree(&val);
}

bool AUuidFromString(const char* str, A_UUID& uuid)
{
	return RPC_S_OK==UuidFromStringA((unsigned char*)str, (UUID*)&uuid);
}

void AUuidGenerate(A_UUID& uuid)
{
	UuidCreate((UUID*)&uuid);
}
#else
#include <uuid.h>
void AUuidToString(const A_UUID& uuid, char* str)
{
	uint32_t status;
	uuid_to_string(str, (const uuid_t*)&uuid, &status);
}

bool AUuidFromString(const char* str, A_UUID& uuid)
{
	uint32_t status;
	uuid_from_string((uuid_t*)&uuid, &status);
	return status==uuid_s_ok;
}

void AUuidGenerate(A_UUID& uuid)
{
	uint32_t status
	uuid_create((uuid_t*)&uuid, &status);
}

#endif